import Vue from 'vue';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import axios from 'axios';
import VueAxios from 'vue-axios';
// 导入格式化时间的插件
import moment from 'moment';
import App from './App';
import router from './router';
import Vuex from 'vuex'
Vue.use(Vuex)
Vue.use(VueAxios, axios);
Vue.use(ElementUI);

var userinfo=JSON.parse(localStorage.getItem('userinfo') || '[]')

var store=new Vuex.Store({
  state:{
    userinfo:userinfo
  },
  mutations:{
    updata(state,userinfo){
      state.userinfo=userinfo
      localStorage.setItem("userinfo",JSON.stringify(state.userinfo))
    }
  }
})
// 定义全局的过滤器
Vue.filter('dateFormat', function (dataStr, pattern = "YYYY-MM-DD") {
  return moment(dataStr).format(pattern)
})
Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
